define(['jquery'],function($){

    $.fn.extend({
        //图片截取
        imageZoom:function(width, height){
            return this.each(function () {
                var obj=this;
                var img=new Image(); 
                img.src=obj.src; 
                var scale=Math.max(width/img.width, height/img.height);
                var newWidth=img.width*scale; 
                var newHeight=img.height*scale;
                var parent=$(obj).parent();
                $(obj).css({'width': newWidth/64+'rem', 'height': newHeight/64+'rem', 'margin-left': (width-newWidth)/2/64+'rem', 'margin-top': (height-newHeight)/2/64+'rem' });
                parent.css({'width':width/64+'rem','height':height/64+'rem','overflow':'hidden'});
                if(img.width < width && img.height < height){
                    newWidth=img.width;
                    newHeight=img.height;
                    $(obj).css({'width': newWidth/64+'rem','height': newHeight/64+'rem','margin-left':'0rem','margin-top': (height-newHeight)/2/64+'rem'});
                }
            });
        },
        //公告滚动
        callboard:function(time){
            return this.each(function () {
                var obj=$(this);
                var callboarTimer; 
                var callboardUl = obj.find('ul'); 
                var callboardLi = obj.find('li');
                var liLen = obj.find('li').length; 
                var initHeight = callboardLi.first().outerHeight(true); 
                var autoAnimation = function (){
                    if (liLen <= 1) return; 
                    var self = arguments.callee; 
                    var callboardLiFirst = obj.find('li').first(); 
                    callboardLiFirst.animate({ 
                        marginTop:-initHeight 
                    }, 500, function (){ 
                        clearTimeout(callboarTimer); 
                        callboardLiFirst.appendTo(callboardUl).css({marginTop:0}); 
                        callboarTimer = setTimeout(self, time); 
                    }); 
                } 
                obj.mouseenter(function (){ 
                    clearTimeout(callboarTimer); 
                }).mouseleave(function (){ 
                    callboarTimer = setTimeout(autoAnimation(), time); 
                });
                setTimeout(autoAnimation(), time); 
            });
        }

    });
});